/*package com.nuanshui.heatedloan.extension.interceptor;

import org.apache.commons.lang3.StringUtils;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

public class CORSInterceptor implements HandlerInterceptor {
	
	static List<String> siteUrlList=new ArrayList<String>();
	
	private boolean isValidUrl(String origin)
	{
		if(siteUrlList.size()==0)
		{
			siteUrlList.add("http://m.ikebohui.com");
			siteUrlList.add("http://manage.ikebohui.com");
			siteUrlList.add("http://localhost:8001/");
		}
		
		boolean bFlag=false;
		for (String strUrl : siteUrlList) { 
			if(StringUtils.isEmpty(strUrl))
				continue;
			
			if(strUrl.contains(origin))
			{
				bFlag=true;
				break;
			}
		}
		return bFlag;
	}

	@Override
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
		String origin = request.getHeader("Referer");
		String requestMethod = request.getMethod();
		
		
		if(origin == null || requestMethod == null) return true;
		
		URL siteUrl=new URL(origin);
		boolean bFlag=isValidUrl(siteUrl.getHost());
		if(bFlag && (requestMethod.equals("POST") || requestMethod.equals("GET"))) {
			HttpServletResponse responseHeaders = response;
			
			StringBuffer sb=new StringBuffer();
			sb.append(siteUrl.getProtocol());
			sb.append("://");
			sb.append(siteUrl.getHost());
			if(siteUrl.getPort()>0)
			{
				sb.append(":");
				sb.append(siteUrl.getPort());
			}
			
			responseHeaders.setHeader("Access-Control-Allow-Origin", sb.toString());
			responseHeaders.setHeader("Access-Control-Allow-Methods", "GET,POST,PUT,DELETE,OPTIONS");
			responseHeaders.setHeader("Access-Control-Allow-Credentials", "true");
			responseHeaders.setHeader("Access-Control-Allow-Headers", "openid,safetoken,userid,accept,channel");
			//responseHeaders.setHeader("Access-Control-Max-Age", "3600");
			System.out.println("-----------------拦截跨域POST请求---------------");
		}
		
		return true;
	}

	@Override
	public void postHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler,
			ModelAndView modelAndView) throws Exception {
		// TODO Auto-generated method stub
		//Map<String, Object> res = modelAndView.getModel();
		//System.out.println(JSON.toJSONString(res));
		//System.out.println(response.getHeaderNames().toString());
		
		//System.out.println("-----------------拦截跨域POST请求---------------");
	}

	@Override
	public void afterCompletion(HttpServletRequest request,
			HttpServletResponse response, Object handler, Exception ex)
			throws Exception {
		// TODO Auto-generated method stub
		//System.out.println("xxxxxxxxxxxxxxxxxxxxx------拦截方法----------------");
	}

	
}
*/